try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}
$(document).ready(function(){
	$('.handle > div > .close').click(function(){
		$(this).parent().fadeOut('normal');
	});
	$('a[action]').click(function(){(window[$(this).attr('action')])(this);return false;});
	$('[copy="true"]:first').each(function(){
		  ZeroClipboard.elem=$(this);
		  ZeroClipboard.text=$(this).text();
		  ZeroClipboard.append();
	});
	$('div.label > a').click(function(){
		$(this).toggleClass('select');
		var name='',label='',append=$('div.append'),select=$('a.select');
		if(select.length==0){
			append.find('label').text(append.find('label').attr('alt'));
		}else{
			$('a.select').each(function(){
				label+=$(this).attr('id')+',';
				name+=$(this).find('span').text()+',';
			});
			label=label.slice(0,-1);name=name.slice(0,-1);
	  		append.find('input').attr('value',label);
	  		append.find('label').text(name);
		}
  		return false;
  	});
  	$('.label_sub > input,div.append').click(function(){
  		var label=$('.label');
  		if(label.css('display')=='none'){
  			height=label.outerHeight();
  			label.css('height','0px').css('display','block');
  			label.animate({'height':height},300);
  		}else{
  			label.animate({'height':'0px'},300,function(){
  				label.css('display','none').css('height','auto');
  			});
  		}
  		return false;
  	});
});
function del(obj){
	if(window.confirm('你确定要删除吗?')){
		$.getJSON($(obj).attr('href'),function(json){
			if(json.state=='success'){
			}else{
				
			}
		});
	}
}
function complete(){
	alert('成功复制到剪切板.');
}
ZeroClipboard={
	elem:null,swf:'',text:'',load:false,
    append:function(){
		var obj=this.elem.next('.zcopy');
		obj.attr('id','zclipdiv');
		obj.html(this.getHTML(obj.outerWidth(),obj.outerHeight()));
    },
    getHTML:function(width,height){
        var html = '';
        var flashvars='id=zclipdiv&width='+width+'&height='+height;
        if(navigator.userAgent.match(/MSIE/)){
            var protocol=location.href.match(/^https/i)?'https://':'http://';
            html+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' + protocol + 'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + width + '" height="'+height+'" id="zclip" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+this.swf+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="' + flashvars + '"/><param name="wmode" value="transparent"/></object>';
        }else{
            html+='<embed id="zclip" src="'+this.swf+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width + '" height="'+ height + '" name="zclipdiv" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + flashvars + '" wmode="transparent" />';
        }
        return html;
    },
    setText:function(Text){
        if(this.load){document.getElementById('zclip').setText(Text);}
    },
	dispatch:function(id,eventName,args){
		if(eventName=='load'){this.load=true;this.setText(this.text);}
		if(window[eventName]){(window[eventName])();}
    }
};
function DdvertSub(){
	if($('input[name="name"]')==''){
		alert('名称不可为空.');
	}else if($('input[name="adcolumn"]').attr('value')==''){
		alert('广告栏标签不可为空.');
	}else if($('select[name="modality_tmp"]').attr('value')=='0'){
		alert('展现形式不可为空.');
	}else if($('select[name="modality"]').attr('value')=='0'){
		alert('广告尺寸不可为空.');
	}else{
		return true;
	}
	return false;
}